#include "MaterialPropertyNodeModel.h"

#include "MaterialGraph/Pin/MaterialGraphPinModel.h"
#include "Object/NewObject.h"

void RMaterialPropertyNodeModel::FirstTimeInitializeObject()
{
    //add UV output pin
    auto UVOutputPin = NewObject<RMaterialGraphPinModel>(this);
    UVOutputPin->ValueType= EMaterialGraphValueType::Vector2D;
    UVOutputPin->bIsOutput = true;
    Outputs.Add(UVOutputPin);

    //add position output pin
    auto PositionOutputPin = NewObject<RMaterialGraphPinModel>(this);
    PositionOutputPin->ValueType = EMaterialGraphValueType::Vector3D;
    PositionOutputPin->bIsOutput = true;
    Outputs.Add(PositionOutputPin);

}

CString RMaterialPropertyNodeModel::GenerateExpression()
{
    CString Result;
    if(Outputs[0]->HasValidLink())
    {
        Result+=
            U"vec2 "+Outputs[0]->UniqueOutputPinName+U" = inUV;\n";
    }

    if(Outputs[1]->HasValidLink())
    {
        Result+=
            U"vec3 "+Outputs[1]->UniqueOutputPinName+U" = inWorldPos;\n";
    }

    return Result;
}
